from flask import Blueprint
from peewee import DoesNotExist

from app.text import views

bp = Blueprint("text", __name__, url_prefix="text/")


@bp.errorhandler(DoesNotExist)
def handle_not_exist(error):
    return "no record", 404


bp.add_url_rule(
    "/content/<int:content_id>",
    view_func=views.ContentEdit.as_view("content_edit"),
    methods=["PUT", "DELETE"],
)

bp.add_url_rule(
    "/content", view_func=views.Content.as_view("content"), methods=["POST"]
)

bp.add_url_rule(
    "/content", view_func=views.Contents.as_view("contents"), methods=["GET"]
)
